/*=====================================================================================================================
 * 
 * Repository path:     $HeadURL: http://sstu.googlecode.com/svn/tags/sstu-v40.24-dsPIC30F3014/src/traps.c $
 * Last committed:      $Revision: 32 $
 * Last changed by:     $Author: vladislav.gyurov@gmail.com $
 * Last changed date:   $Date: 2014-03-10 19:38:23 +0000 (Mon, 10 Mar 2014) $
 * ID:                  $Id: traps.c 32 2014-03-10 19:38:23Z vladislav.gyurov@gmail.com $
 *
 *===================================================================================================================*/

/*----------------------------------------------------------------------------*/
/* Body Identification                                                        */
/*----------------------------------------------------------------------------*/
#ifdef TRAPS_C
    #error "!!! FileName ID. It should be Unique !!!"
#else
    #define TRAPS_C
#endif
/*----------------------------------------------------------------------------*/
/* Included files to resolve specific definitions in this file                */
/*----------------------------------------------------------------------------*/
#include "basedef.h"
#include "LCD.h"

/*----------------------------------------------------------------------------*/
/* Local constants                                                            */
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
/* Local macros                                                               */
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
/* Local types                                                                */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* Local data                                                                 */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* Constant local data                                                        */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* Exported data                                                              */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* Constant exported data                                                     */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* Local function prototypes                                                  */
/*----------------------------------------------------------------------------*/
void __attribute__((__interrupt__)) _OscillatorFail(void);
void __attribute__((__interrupt__)) _AddressError(void);
void __attribute__((__interrupt__)) _StackError(void);
void __attribute__((__interrupt__)) _MathError(void);

/******************************************************************************/
/*                                                                            */
/*                           T R A P    H A N D L E R S                       */
/*                                                                            */
/******************************************************************************/
/******************************************************************************/
/*
* Purpose: 
* Input: 
* Output:  
*/
/******************************************************************************/
void __attribute__((interrupt, no_auto_psv)) _OscillatorFail(void)
{
        INTCON1bits.OSCFAIL = 0;        //Clear the trap flag
        IF_LCDPutc('\f');
        IF_LCDPuts("OSCILLATOR FAIL");
        while (1);
}
/******************************************************************************/
/*
* Purpose: 
* Input: 
* Output:  
*/
/******************************************************************************/
void __attribute__((interrupt, no_auto_psv)) _AddressError(void)
{
        INTCON1bits.ADDRERR = 0;        //Clear the trap flag
        IF_LCDPutc('\f');
        IF_LCDPuts("ADDRESS ERROR");
        while (1);
}

/******************************************************************************/
/*
* Purpose: 
* Input: 
* Output:  
*/
/******************************************************************************/
void __attribute__((interrupt, no_auto_psv)) _StackError(void)
{

        INTCON1bits.STKERR = 0;         //Clear the trap flag
        IF_LCDPutc('\f');
        IF_LCDPuts("STACK ERROR");
        while (1);
}
/******************************************************************************/
/*
* Purpose: 
* Input: 
* Output:  
*/
/******************************************************************************/
void __attribute__((interrupt, no_auto_psv)) _MathError(void)
{
        INTCON1bits.MATHERR = 0;        //Clear the trap flag
        IF_LCDPutc('\f');
        IF_LCDPuts("MATH ERROR");
        while(1);
}

/******************************************************************************/
/*                                                                            */
/*                       L O C A L   F U N C T I O N S                        */
/*                                                                            */
/******************************************************************************/

/******************************************************************************/
/*
 * Name:      
 * Purpose:   
 * 
*/
/******************************************************************************/

